<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'tracker',
	'defaultController'=>'tracker',

	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>require(dirname(__FILE__).'/params.php'),
	'widgets'=> array(
		'UserLogin',
		'MainMenu',
		'UserMenu',
	),

	// application components
	'components'=>array(

		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
			),
		),

		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
			// force 401 HTTP error if authentication needed
			'loginUrl'=>null,
		),

		'db'=>array(
			'connectionString'=>'mysql:host=localhost;dbname=atom',
			'username'=>'yii',
			'password'=>'yii',
		),

		'rbacEx' => array(
			'class' => 'application.components.RbacEx',
		),

		'urlManager'=>array(
			'urlFormat'=>'path',
			'showScriptName' => false,
			'rules'=>array(
				'getUserBag'=>'user/getUserBag',
				'setUserBag'=>'user/setUserBag',
				
				'torrent/upload' => 'torrent/upload',
				'torrent/download/<id:\d+>' => 'torrent/download',
				'torrent/delete/<id:\d+>' => 'torrent/delete',
				'torrent/show/<id:\d+>' => 'torrent/show',
				
				'register' => 'tracker/register',
				'login' => 'tracker/login',
				'logout' => 'tracker/logout',

				'announce' => 'tracker/announce',
				'scrape' => 'tracker/scrape',

				'admin' => 'admin/index',
				'admin/users' => 'admin/users',
				'admin/roles' => 'admin/roles',
				'admin/user/edit/<id:\d+>' => '/user/edit',
				'admin/user/details/<id:\d+>' => '/user/details',
				'admin/user/permissions/<id:\d+>' => '/user/permissions',
				'admin/role/edit/<id:\d+>' => '/role/edit',

				'role/edit/<id:\d+>' => 'role/edit',

				'user/edit/<id:\d+>' => 'user/edit',
				'user/delete/<id:\d+>' => 'user/delete',
				'user/details/<id:\d+>' => 'user/details',
				'user/permissions/<id:\d+>' => 'user/permissions',

			),
		),
	),
);